<?php
/**
 * Created by PhpStorm.
 * User: xuzhong
 * Date: 2025/4/2
 * Time: 13:55
 */

namespace app\admin\model;
use think\Model;

class  StaffInfo extends BaseModel
{
    // 定义数据表名
    protected $name = 'staff_info';

    // 定义主键
    protected $primaryKey = 'id';

    // 定义创建时间字段名
    protected $createTime = 'create_time';

    // 定义更新时间字段名
    protected $updateTime = 'update_time';
    // 定义自动时间戳
    protected $autoWriteTimestamp = true;

    // 设置字段信息
    protected $schema = [
        'id'          => 'int',
        'worknumber'       => 'string',
        'fullname'       => 'string',
        'avator'      => 'string',
        'job'       => 'string',
        'describe'       => 'string',
        'email'          => 'string',
        'phone'      => 'string',
        'telegramid'    => 'string',
        'twitterid'    => 'string',
        'tiktokid'     => 'string',
        'lineid'     => 'string',
        'wechat'  => 'string',
        'ins'  => 'string',
        'zaloid'  => 'string',
        'linkedin'  => 'string',
        'facebook'  => 'string',
        'whatsapp'    => 'string',
        'website'       => 'string',
        'create_time' => 'datetime',
        'creator'     => 'int',
        'is_del'      => 'int',
        'support_language'    => 'string',
        'if_show'      => 'int',
    ];
    protected $attributes = [
        'language'=>[
            'English'=>'英语',
            'French'=>'法语',
            'German'=>'德语',
            'Italian'=>'意大利语',
            'Spanish'=>'西班牙语',
            'Portuguese'=>'葡萄牙语',
            'Russian'=>'俄语',
            'Dutch'=>'荷兰语',
            'Arabic'=>'阿拉伯语',
            'Chinese'=>'中文',
            'Indonesian'=>'印尼语',
            'Vietnamese'=>'越南语',
            'Japanese'=>'日语',
            'Korean'=>'韩语',
            'Bengali'=>'孟加拉语',
            'Hindi'=>'印地语',
            'Urdu'=>'乌尔都语',
        ],
        'if_show' => [
            0 =>'否',
            1 =>'是',
        ],
    ];

    public function getAttr($name)
    {
        // 检查是否是要处理的特殊属性
        if (strpos($name, '_value') !== false) {
            $originalField = str_replace('_value', '', $name);
            if (isset($this->attributes[$originalField])) {
                $value = $this->getData($originalField);
                return $this->attributes[$originalField][$value] ?? '未知';
            }
        }

        // 如果不是特殊属性，调用父类的方法
        return parent::getAttr($name);
    }

    /**
     * @describe
     * @author: Bobo
     * @date: 2025-02-11 17:05:24
     * @param [type] @required
     * @return Renderable
     */
    public function getFieldEnum($field = 'all')
    {
        return $this->getEnum(strtoupper($field), [], 'label');
    }

}